package com.tm.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tm.dto.StaffQueryDTO;
import com.tm.entity.StaffEntity;
import com.tm.service.StaffService;
import com.tm.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @PROJECT_NAME: tm-wm-syb
 * @DESCRIPTION:
 * @USER: DELL
 * @DATE: 2023/4/10 8:13
 */
@RestController
@RequestMapping("employee")
public class StaffController {
    @Autowired
    private StaffService staffService;

    @PostMapping("page")
    public R query(@RequestBody StaffQueryDTO staffQueryDto){
        Page<StaffEntity> page = staffService.abc(staffQueryDto);
        return R.success(page);
    }

    @PostMapping("add")
    public R add(@RequestBody StaffEntity staffEntity){
        boolean save = staffService.save(staffEntity);
        return R.success(save);
    }

    @PutMapping("update")
    public R update(@RequestBody StaffEntity staffEntity){
        boolean b = staffService.updateById(staffEntity);
        return R.success(b);
    }
}
